$(function () {
    /**
     * banner
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.banner,
        type: 'GET',
        dataType: 'json',
        data: {}
    }, function (res) {

        $('#banner').html(template('bannerTpl', {'res': res}));
        // var script = $('<script src="js/slider/slider.js"></script>');   //创建script标签
        // $('body').append(script);
        var swiper = new Swiper('.banner', {
            navigation: {
              nextEl: '.banner .swiper-button-next',
              prevEl: '.banner .swiper-button-prev',
            },
            pagination: {
              el: '.banner .swiper-pagination',
              clickable : true
            },
            loop:true,
            autoplay : true
        });
    })


    /**
     * 教学
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.fixedGoods,
        type: 'GET',
        dataType: 'json',
        data: {
            goods_type: 2
        }
    }, function (res) {

        $('#slider').html(template('sliderTpl', {'res': res}));
        var swiper = new Swiper('.slider', {
            slidesPerView: 4,
            spaceBetween: 30,
            slidesPerGroup: 4,
            loop: true,
            loopFillGroupWithBlank: true,
            pagination: {
                el: '.slider .swiper-pagination',
                clickable: true,
            },
            navigation: {
                nextEl: '.slider .swiper-button-next',
                prevEl: '.slider .swiper-button-prev',
            },
            mousewheel: false,
        });
    })
    /**
     * 行测
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.fixedGoods,
        type: 'GET',
        dataType: 'json',
        data: {
            goods_type: 1
        }
    }, function (res) {

        $('#listke').html(template('listkeTpl', {'res': res}));
    })

    /**
     * 分类导航
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.classify,
        type: 'GET',
        dataType: 'json',
        data: {}
    }, function (res) {

        $('#classify').html(template('classifyTpl', {'res': res}));
    })

    /**
     * 培训动态
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.tidings,
        type: 'GET',
        dataType: 'json',
        data: {}
    }, function (res) {
        $('#listdt').html(template('listdtTpl', {'res': res}));
        send();
    });

    function send() {
        $(".demo2").bootstrapNews({
            newsPerPage: 20,
            autoplay: true,
            pauseOnHover: true,
            navigation: false,
            direction: 'down',
            newsTickerInterval: 2500,
            onToDo: function () {
                //console.log(this);
            }
        });
    }

    /**
     * 名师列表
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.teacher,
        type: 'GET',
        dataType: 'json',
        data: {}
    }, function (res) {

        $('#teacher').html(template('teacherTpl', {'res': res}));
    })

    /**
     * 友情链接
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.links,
        type: 'GET',
        dataType: 'json',
        data: {}
    }, function (res) {

        $('#links').html(template('linksTpl', {'res': res}));
    })


    // $('body').on('click', '.swiper-slide', function () {

    //     window.open(HOME.locationVal.origin + '/info.html')
    // })

    $('body').on('click', '.charge_more', function () {
        // window.open(HOME.locationVal.origin + '/line.html')
    })

   


})